﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsTongHop
    {
        private string mChungTuDinhKem = "";
        private string mDiaChi = "";
        private string mDienGiai = "";
        private string mDienThoai = "";
        private string mDuLieu = "";
        private int mDuyet = 0;
        private string mKhoa = "";
        private string mKhoaChungTuThamChieu = "";
        private string mKhoaDonVi = "";
        private string mKhoaNhanVienCapNhat = "";
        private string mKhoaNhanVienTao = "";
        private string mLoaiChungTu = "";
        private string mLoaiChungTuThamChieu = "";
        private string mLoaiTien = "";
        private string mNgayCapNhat = "";
        private string mNgayChungTu = "";
        private string mNgayChungTuThamChieu = "";
        private string mNgayTao = "";
        private string mNguoiDaiDien = "";
        private int mSend = 0;
        private string mSoChungTu = "";
        private string mSoChungTuThamChieu = "";
        private string mSoCMND = "";
        private double mSoTien = 0.0;
        private double mSoTienNT = 0.0;
        private double mTyGia = 0.0;

        public void ClearTemp(string pKeyTable)
        {
            string commandText = "DELETE FROM GL_TongHopChiTietTmp WHERE KhoaChungTu = '" + pKeyTable.Trim() + "'";
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
        }

        public bool DeleteData(string strKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[4];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@CheckAmQuy", DbType.Double, ParameterDirection.Input, 1);
                commandParameters[2] = DBHelper.createParameter("@AmQuy", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[3] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_TongHopDel", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[2].Value, 0, false))
                {
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[3].Value, 0, false))
                    {
                        LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m quỹ!", ""));
                    }
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetDataPrint(string strKhoa)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Input, 0);
                return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_BC_ChungTuTongHop", commandParameters).Tables[0];
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[1].Value, 0, false))
                {
                    return null;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetList(string strCondition = "")
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                string commandText = "SELECT DISTINCT TH.Khoa, TH.SoChungTu, dbo.Char2Date(TH.NgayChungTu) as Ngay, TH.ChungTuDinhKem,  TH.SoTienNT, TH.SoTien, TH.DienGiai, TH.NgayChungTu  FROM GL_TongHop TH LEFT JOIN GL_TongHopChiTiet CT ON TH.Khoa = CT.KhoaChungTu " + str2 + " ORDER BY  TH.NgayChungTu, TH.SoChungTu ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDetails(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaTaiKhoanNo, TKN.SoTaiKhoan as TaiKhoanNo, CT.KhoaDoiTuongNo, DTN.Ten" + modGeneral.H_LANGUAGE + " as DoiTuongNo,  CT.KhoaTaiKhoanCo, TKC.SoTaiKhoan As TaiKhoanCo, CT.KhoaDoiTuongCo, DTC.Ten" + modGeneral.H_LANGUAGE + " as DoiTuongCo,  CT.KhoaChungTuThamChieu, CT.SoChungTuThamChieu, dbo.Char2Date(CT.NgayChungTuThamChieu) As NgayChungTuThamChieu,  CT.SoTienNT, CT.SoTien, CT.KhoaTaiKhoanThue, TKT.SoTaiKhoan as TaiKhoanThue, CT.Ve,   CT.KhoaLoaiThue, LoaiThue = CASE LEFT(TKT.SoTaiKhoan,3) WHEN '133' THEN HM.Ma WHEN '333' THEN LT.MA END,  CT.TyLeThue, CT.TienThueNT, CT.TienThue, CT.SoHoaDon, dbo.Char2Date(CT.NgayHoaDon) as NgayHoaDon,  CT.SoSeri, CT.KhoaDoiTuongThue, CT.TenDoiTuongThue, CT.MaSoThue, CT.DiaChiThue, CT.DienGiai,  CT.KhoaBoPhanNo, BPN.Ten" + modGeneral.H_LANGUAGE + " as BoPhanNo,  CT.KhoaSanPhamNo, SPN.Ten" + modGeneral.H_LANGUAGE + " as SanPhamNo, CT.KhoaHopDongNo, HDN.SoHopDong As SoHopDongNo,  CT.KhoaKhoanMucNo, CPN.Ten" + modGeneral.H_LANGUAGE + " As KhoanMucChiPhiNo,  CT.KhoaBoPhanCo, BPC.Ten" + modGeneral.H_LANGUAGE + " as BoPhanCo,  CT.KhoaSanPhamCo, SPC.Ten" + modGeneral.H_LANGUAGE + " as SanPhamCo, CT.KhoaHopDongCo, HDN.SoHopDong As SoHopDongCo,  CT.KhoaKhoanMucCo, CPC.Ten" + modGeneral.H_LANGUAGE + " As KhoanMucChiPhiCo  FROM GL_TongHopChiTiet CT  LEFT JOIN DM_TaiKhoan TKN on CT.KhoaTaiKhoanNo = TKN.Khoa  LEFT JOIN DM_TaiKhoan TKC on CT.KhoaTaiKhoanCo = TKC.Khoa  LEFT JOIN DM_TaiKhoan TKT on CT.KhoaTaiKhoanThue = TKT.Khoa  LEFT JOIN DM_DoiTuong DTN on CT.KhoaDoiTuongNo = DTN.Khoa  LEFT JOIN DM_DoiTuong DTC on CT.KhoaDoiTuongCo = DTC.Khoa  LEFT JOIN DM_DonViBoPhan BPN on CT.KhoaBoPhanNo = BPN.Khoa  LEFT JOIN DM_DonViBoPhan BPC on CT.KhoaBoPhanCo = BPC.Khoa  LEFT JOIN DM_SanPhamCongViec SPN on CT.KhoaSanPhamNo = SPN.Khoa  LEFT JOIN DM_SanPhamCongViec SPC on CT.KhoaSanPhamCo = SPC.Khoa  LEFT JOIN DM_HopDong HDN on CT.KhoaHopDongNo = HDN.Khoa  LEFT JOIN DM_HopDong HDC on CT.KhoaHopDongCo = HDC.Khoa  LEFT JOIN DM_KhoanMucChiPhi CPN on CT.KhoaKhoanMucNo = CPN.Khoa  LEFT JOIN DM_KhoanMucChiPhi CPC on CT.KhoaKhoanMucCo = CPC.Khoa  LEFT JOIN DM_LoaiHoaDon LT on CT.KhoaLoaiThue = LT.Khoa  LEFT JOIN DM_HangMucBaoCaoThue HM ON CT.KhoaLoaiThue = HM.Khoa  WHERE CT.KhoaChungTu = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDetailsMuaVao(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaTaiKhoanNo, TKN.SoTaiKhoan as TaiKhoanNo, CT.KhoaDoiTuongNo, DTN.Ten" + modGeneral.H_LANGUAGE + " as DoiTuongNo,  CT.KhoaTaiKhoanCo, TKC.SoTaiKhoan As TaiKhoanCo, CT.KhoaDoiTuongCo, DTC.Ten" + modGeneral.H_LANGUAGE + " as DoiTuongCo,  CT.KhoaChungTuThamChieu, CT.SoChungTuThamChieu, dbo.Char2Date(CT.NgayChungTuThamChieu) As NgayChungTuThamChieu,  CT.SoTienNT, CT.SoTien, CT.KhoaTaiKhoanThue, TKT.SoTaiKhoan as TaiKhoanThue, CT.Ve,   CT.KhoaLoaiThue, LT.Ma as LoaiThue,  CT.TyLeThue, CT.TienThueNT, CT.TienThue, CT.SoHoaDon, dbo.Char2Date(CT.NgayHoaDon) as NgayHoaDon,  CT.SoSeri, CT.KhoaDoiTuongThue, CT.TenDoiTuongThue, CT.MaSoThue, CT.DiaChiThue, CT.DienGiai,  CT.KhoaBoPhanNo, BPN.Ten" + modGeneral.H_LANGUAGE + " as BoPhanNo,  CT.KhoaSanPhamNo, SPN.Ten" + modGeneral.H_LANGUAGE + " as SanPhamNo, CT.KhoaHopDongNo, HDN.SoHopDong As SoHopDongNo,  CT.KhoaKhoanMucNo, CPN.Ten" + modGeneral.H_LANGUAGE + " As KhoanMucChiPhiNo,  CT.KhoaBoPhanCo, BPC.Ten" + modGeneral.H_LANGUAGE + " as BoPhanCo,  CT.KhoaSanPhamCo, SPC.Ten" + modGeneral.H_LANGUAGE + " as SanPhamCo, CT.KhoaHopDongCo, HDN.SoHopDong As SoHopDongCo,  CT.KhoaKhoanMucCo, CPC.Ten" + modGeneral.H_LANGUAGE + " As KhoanMucChiPhiCo  FROM GL_TongHopChiTiet CT  LEFT JOIN DM_TaiKhoan TKN on CT.KhoaTaiKhoanNo = TKN.Khoa  LEFT JOIN DM_TaiKhoan TKC on CT.KhoaTaiKhoanCo = TKC.Khoa  LEFT JOIN DM_TaiKhoan TKT on CT.KhoaTaiKhoanThue = TKT.Khoa  LEFT JOIN DM_DoiTuong DTN on CT.KhoaDoiTuongNo = DTN.Khoa  LEFT JOIN DM_DoiTuong DTC on CT.KhoaDoiTuongCo = DTC.Khoa  LEFT JOIN DM_DonViBoPhan BPN on CT.KhoaBoPhanNo = BPN.Khoa  LEFT JOIN DM_DonViBoPhan BPC on CT.KhoaBoPhanCo = BPC.Khoa  LEFT JOIN DM_SanPhamCongViec SPN on CT.KhoaSanPhamNo = SPN.Khoa  LEFT JOIN DM_SanPhamCongViec SPC on CT.KhoaSanPhamCo = SPC.Khoa  LEFT JOIN DM_HopDong HDN on CT.KhoaHopDongNo = HDN.Khoa  LEFT JOIN DM_HopDong HDC on CT.KhoaHopDongCo = HDC.Khoa  LEFT JOIN DM_KhoanMucChiPhi CPN on CT.KhoaKhoanMucNo = CPN.Khoa  LEFT JOIN DM_KhoanMucChiPhi CPC on CT.KhoaKhoanMucCo = CPC.Khoa  LEFT JOIN DM_HangMucBaoCaoThue LT on CT.KhoaLoaiThue = LT.Khoa  WHERE CT.KhoaChungTu = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetNhatKyChungTu(string strTuNgay, string strDenNgay, string strKhoaDonVi)
        {
            DataTable table;
            try
            {
                string commandText = "  SELECT NK.KhoaChungTu, NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as Ngay, NK.SoHoaDon, TKN.SoTaiKhoan as TaiKhoanNo, TKC.SoTaiKhoan As TaiKhoanCo, NK.LoaiTien, NK.SoPhatSinh, NK.DienGiai  FROM GL_NhatKyChungTu NK  LEFT JOIN DM_TaiKhoan TKN on NK.KhoaTaiKhoanNo = TKN.Khoa  LEFT JOIN DM_TaiKhoan TKC on NK.KhoaTaiKhoanCo = TKC.Khoa  WHERE NK.KhoaDonVi = '" + strKhoaDonVi.Trim() + "' and (NK.NgayChungTu Between '" + strTuNgay + "' and '" + strDenNgay + "') ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public void GetSoTaiKhoan(string strKhoa, ref string strTKNo, ref string strTKCo)
        {
            string commandText = "";
            clsDMTaiKhoan khoan = new clsDMTaiKhoan();
            int num = 0;
            strTKNo = "";
            strTKCo = "";
            try
            {
                this.Load(strKhoa);
                commandText = "SELECT Distinct(SoTaiKhoan) as SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTaiKhoanCo  FROM GL_TongHopChiTiet Where KhoaChungTu = '" + strKhoa + "')";
                DataTable table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                if (table != null)
                {
                    int num2 = table.Rows.Count - 1;
                    for (num = 0; num <= num2; num++)
                    {
                        if (strTKCo.Trim() == "")
                        {
                            strTKCo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                        }
                        else
                        {
                            strTKCo = strTKCo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                        }
                    }
                    commandText = "SELECT Distinct(SoTaiKhoan) as SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTaiKhoanNo  FROM GL_TongHopChiTiet Where KhoaChungTu = '" + strKhoa + "')";
                    table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                    if (table != null)
                    {
                        int num3 = table.Rows.Count - 1;
                        for (num = 0; num <= num3; num++)
                        {
                            if (strTKNo.Trim() == "")
                            {
                                strTKNo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                            }
                            else
                            {
                                strTKNo = strTKNo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                            }
                        }
                        commandText = "SELECT Distinct(SoTaiKhoan) as SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTaiKhoanThue  FROM GL_TongHopChiTiet Where KhoaChungTu = '" + strKhoa + "' and Rtrim(Ve) = 'CO')";
                        table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                        if (table != null)
                        {
                            int num4 = table.Rows.Count - 1;
                            for (num = 0; num <= num4; num++)
                            {
                                if (strTKCo.Trim() == "")
                                {
                                    strTKCo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                                }
                                else
                                {
                                    strTKCo = strTKCo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                                }
                            }
                            commandText = "SELECT Distinct(SoTaiKhoan) as SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTaiKhoanThue  FROM GL_TongHopChiTiet Where KhoaChungTu = '" + strKhoa + "' and Rtrim(Ve) = 'NO')";
                            table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                            if (table != null)
                            {
                                int num5 = table.Rows.Count - 1;
                                for (num = 0; num <= num5; num++)
                                {
                                    if (strTKNo.Trim() == "")
                                    {
                                        strTKNo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                                    }
                                    else
                                    {
                                        strTKNo = strTKNo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                strTKNo = "";
                strTKCo = "";
                ProjectData.ClearProjectError();
            }
        }

        public bool IsDuplicateVoucherNo(string strVoucherNo, string strKeyTable)
        {
            string commandText = "SELECT * FROM GL_TongHop Where Rtrim(SoChungTu) = '" + strVoucherNo.Trim() + "' AND Khoa <> '" + strKeyTable + "'";
            return (DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0].Rows.Count > 0);
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM GL_TongHop WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mLoaiChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mLoaiChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mNguoiDaiDien = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mDiaChi = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mDienThoai = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mSoCMND = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mChungTuDinhKem = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mNgayTao = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienCapNhat = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mNgayCapNhat = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mSend = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetInt32));
                    this.mDuLieu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mDuyet = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x1c];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[2] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[3] = DBHelper.createParameter("@LoaiChungTu", DbType.Int64, ParameterDirection.Input, this.mLoaiChungTu);
                commandParameters[4] = DBHelper.createParameter("@KhoaChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTuThamChieu);
                commandParameters[5] = DBHelper.createParameter("@SoChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mSoChungTuThamChieu);
                commandParameters[6] = DBHelper.createParameter("@NgayChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTuThamChieu);
                commandParameters[7] = DBHelper.createParameter("@LoaiChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mLoaiChungTuThamChieu);
                commandParameters[8] = DBHelper.createParameter("@NguoiDaiDien", DbType.Int64, ParameterDirection.Input, this.mNguoiDaiDien);
                commandParameters[9] = DBHelper.createParameter("@DiaChi", DbType.Int64, ParameterDirection.Input, this.mDiaChi);
                commandParameters[10] = DBHelper.createParameter("@DienThoai", DbType.Int64, ParameterDirection.Input, this.mDienThoai);
                commandParameters[11] = DBHelper.createParameter("@SoCMND", DbType.Int64, ParameterDirection.Input, this.mSoCMND);
                commandParameters[12] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[13] = DBHelper.createParameter("@ChungTuDinhKem", DbType.Int64, ParameterDirection.Input, this.mChungTuDinhKem);
                commandParameters[14] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[15] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[0x10] = DBHelper.createParameter("@SoTienNT", DbType.Date, ParameterDirection.Input, this.mSoTienNT);
                commandParameters[0x11] = DBHelper.createParameter("@SoTien", DbType.Date, ParameterDirection.Input, this.mSoTien);
                commandParameters[0x12] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x13] = DBHelper.createParameter("@KhoaNhanVienTao", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienTao);
                commandParameters[20] = DBHelper.createParameter("@NgayTao", DbType.Int64, ParameterDirection.Input, this.mNgayTao);
                commandParameters[0x15] = DBHelper.createParameter("@KhoaNhanVienCapNhat", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienCapNhat);
                commandParameters[0x16] = DBHelper.createParameter("@NgayCapNhat", DbType.Int64, ParameterDirection.Input, this.mNgayCapNhat);
                commandParameters[0x17] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                commandParameters[0x18] = DBHelper.createParameter("@DuLieu", DbType.Int64, ParameterDirection.Input, this.mDuLieu);
                commandParameters[0x19] = DBHelper.createParameter("@Duyet", DbType.Double, ParameterDirection.Input, this.mDuyet);
                commandParameters[0x1a] = DBHelper.createParameter("@AmQuy", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[0x1b] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_TongHop", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(commandParameters[0x1b].Value, 0, false))
                {
                    return true;
                }
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[0x1a].Value, 0, false))
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m quỹ!", ""));
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string ChungTuDinhKem
        {
            get
            {
                return this.mChungTuDinhKem;
            }
            set
            {
                this.mChungTuDinhKem = value;
            }
        }

        public string DiaChi
        {
            get
            {
                return this.mDiaChi;
            }
            set
            {
                this.mDiaChi = value;
            }
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string DienThoai
        {
            get
            {
                return this.mDienThoai;
            }
            set
            {
                this.mDienThoai = value;
            }
        }

        public string DuLieu
        {
            get
            {
                return this.mDuLieu;
            }
            set
            {
                this.mDuLieu = value;
            }
        }

        public int Duyet
        {
            get
            {
                return this.mDuyet;
            }
            set
            {
                this.mDuyet = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaChungTuThamChieu
        {
            get
            {
                return this.mKhoaChungTuThamChieu;
            }
            set
            {
                this.mKhoaChungTuThamChieu = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaNhanVienCapNhat
        {
            get
            {
                return this.mKhoaNhanVienCapNhat;
            }
            set
            {
                this.mKhoaNhanVienCapNhat = value;
            }
        }

        public string KhoaNhanVienTao
        {
            get
            {
                return this.mKhoaNhanVienTao;
            }
            set
            {
                this.mKhoaNhanVienTao = value;
            }
        }

        public string LoaiChungTu
        {
            get
            {
                return this.mLoaiChungTu;
            }
            set
            {
                this.mLoaiChungTu = value;
            }
        }

        public string LoaiChungTuThamChieu
        {
            get
            {
                return this.mLoaiChungTuThamChieu;
            }
            set
            {
                this.mLoaiChungTuThamChieu = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string NgayCapNhat
        {
            get
            {
                return this.mNgayCapNhat;
            }
            set
            {
                this.mNgayCapNhat = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayChungTuThamChieu
        {
            get
            {
                return this.mNgayChungTuThamChieu;
            }
            set
            {
                this.mNgayChungTuThamChieu = value;
            }
        }

        public string NgayTao
        {
            get
            {
                return this.mNgayTao;
            }
            set
            {
                this.mNgayTao = value;
            }
        }

        public string NguoiDaiDien
        {
            get
            {
                return this.mNguoiDaiDien;
            }
            set
            {
                this.mNguoiDaiDien = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public string SoChungTuThamChieu
        {
            get
            {
                return this.mSoChungTuThamChieu;
            }
            set
            {
                this.mSoChungTuThamChieu = value;
            }
        }

        public string SoCMND
        {
            get
            {
                return this.mSoCMND;
            }
            set
            {
                this.mSoCMND = value;
            }
        }

        public double SoTien
        {
            get
            {
                return this.mSoTien;
            }
            set
            {
                this.mSoTien = value;
            }
        }

        public double SoTienNT
        {
            get
            {
                return this.mSoTienNT;
            }
            set
            {
                this.mSoTienNT = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }
    }
}

